import 'package:flutter/material.dart';
import 'package:acaleph/widget/common_divider.dart';
import 'dart:async';

class CommonPickerSimple extends StatelessWidget {
  const CommonPickerSimple({
    Key key,
    this.activity,
    this.labelText,
    this.hintText,
    this.allActivities,
    this.selectActivity
  }) : super(key: key);

  final String labelText;
  final String hintText;
  final String activity;
  final List<String> allActivities;
  final ValueChanged<String> selectActivity;


  Future<Null> _selectActivity(String newValue) async {
    if (newValue != null )
      selectActivity(newValue);
  }
  @override
  Widget build(BuildContext context) {
   return new DropdownButtonHideUnderline(
      child: new SafeArea(
        top: false,
        bottom: false,
        child: new InputDecorator(
          decoration: new InputDecoration(
            labelText: labelText,
            hintText:  hintText,
          ),
          isEmpty: activity == null,
          child: new DropdownButton<String>(
            value: activity,
            isDense: true,
            onChanged: (String newValue) {
              _selectActivity(newValue);
            },
            items: allActivities.map((String value) {
              return new DropdownMenuItem<String>(
                  value: value,
                  child: new Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      new Expanded(
                        child:  new Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[new Text(value)]
                        ),
                      ),
                      CommonDivider.buildDivider()
                    ],
                  )
              );
            }).toList(),
          ),
        ),
      ),
    );
  }
}
